﻿using ClusterAwareAdmin;
using ClusterAwareProperties;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ClusterAwareAdminTest
{
    
    
    /// <summary>
    ///This is a test class for ClusterManagerAdminTest and is intended
    ///to contain all ClusterManagerAdminTest Unit Tests
    ///</summary>
    [TestClass]
    public class ClusterManagerAdminTest
    {
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        private static ClusterManagerAdmin _manager;

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        [ClassInitialize]
        public static void ClassTestInitialize(TestContext testContext)
        {
        }
        //
        //Use ClassCleanup to run code after all tests in a class have run
        [ClassCleanup]
        public static void ClassTestCleanup()
        {
        }
        //
        //Use TestInitialize to run code before running each test
        [TestInitialize]
        public void Initialize()
        {
            _manager = new ClusterManagerAdmin
            {
                Username = SharedConsts.User,
                Password = SharedConsts.Pwd,
                Domain = SharedConsts.Domain,
                Machine = SharedConsts.Machine,
                CacheInstances = false
            };
            _manager.Connect();
        }
        //
        //Use TestCleanup to run code after each test has run
        [TestCleanup]
        public void Cleanup()
        {
            _manager.Dispose();
        }

        #endregion

        /// <summary>
        ///A test for Dispose
        ///</summary>
        [TestMethod]
        public void DisposeTest()
        {
            _manager.Dispose();
        }

        /// <summary>
        ///A test for Disconnect
        ///</summary>
        [TestMethod]
        public void DisconnectTest()
        {
            _manager.Disconnect();
        }

        /// <summary>
        ///A test for Connect
        ///</summary>
        [TestMethod]
        public void ConnectTest()
        {
            _manager.Connect();
        }

        /// <summary>
        ///A test for ClusterManagerAdmin Constructor
        ///</summary>
        [TestMethod]
        public void ClusterManagerAdminConstructorTest()
        {
            new ClusterManagerAdmin();
        }


        /// <summary>
        ///A test for SetQuorumResource
        ///</summary>
        [TestMethod]
        public void SetQuorumResourceTest()
        {
            Assert.Inconclusive("A method SetQuorumResource implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for SetNodeMajorityQuorum
        ///</summary>
        [TestMethod]
        public void SetNodeMajorityQuorumTest()
        {
            Assert.Inconclusive("A method SetNodeMajorityQuorum implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for SetMajorityQuorum
        ///</summary>
        [TestMethod]
        public void SetMajorityQuorumTest()
        {
            Assert.Inconclusive("A method SetMajorityQuorum implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for SetDiskQuorum
        ///</summary>
        [TestMethod]
        public void SetDiskQuorumTest()
        {
            Assert.Inconclusive("A method SetDiskQuorum implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for Save
        ///</summary>
        [TestMethod]
        public void SaveTest()
        {
            _manager.CacheInstances = true;
            var olddes = _manager.ClusterInfo.Description;
            _manager.ClusterInfo.Description = "TestSave";
            var actual = _manager.Save(_manager.ClusterInfo);
            Assert.AreEqual("TestSave",actual.Description);
            actual.Description = olddes;
            actual = _manager.Save(actual);
            Assert.AreEqual(olddes, actual.Description);
            _manager.CacheInstances = false;
             olddes = _manager.ClusterInfo.Description;
            _manager.ClusterInfo.Description = "TestSave";
             actual = _manager.Save(_manager.ClusterInfo);
            Assert.AreEqual("TestSave", actual.Description);
            actual.Description = olddes;
            actual = _manager.Save(actual);
            Assert.AreEqual(olddes, actual.Description);
        }

        /// <summary>
        ///A test for Rename
        ///</summary>
        [TestMethod]
        public void RenameTest()
        {
            Assert.Inconclusive("A method Rename implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for RemoveResourceToClusterSharedVolumes
        ///</summary>
        [TestMethod]
        public void RemoveResourceToClusterSharedVolumesTest()
        {
            Assert.Inconclusive("A method RemoveResourceToClusterSharedVolumes implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for GetClusterState
        ///</summary>
        [TestMethod]
        public void GetClusterStateTest()
        {
            var sta = _manager.GetClusterState();
            Assert.AreNotEqual(NodeClusterState.Unknown,sta);
        }

        /// <summary>
        ///A test for GetCluster
        ///</summary>
        [TestMethod]
        public void GetClusterTest()
        {
            _manager.CacheInstances = true;
            var actual = _manager.GetCluster();
            Assert.AreNotEqual(null, actual);
            _manager.CacheInstances = false;
             actual = _manager.GetCluster();
            Assert.AreNotEqual(null, actual);
        }

        /// <summary>
        ///A test for ForceCleanup
        ///</summary>
        [TestMethod]
        public void ForceCleanupTest()
        {
            Assert.Inconclusive("A method  ForceCleanup implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for EvictNode
        ///</summary>
        [TestMethod]
        public void EvictNodeTest()
        {
            Assert.Inconclusive("A method SetQuorumResource implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for DestroyCluster
        ///</summary>
        [TestMethod]
        public void DestroyClusterTest()
        {
            Assert.Inconclusive("A method DestroyCluster implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for Create
        ///</summary>
        [TestMethod]
        public void CreateTest()
        {
            Assert.Inconclusive("A method Create implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for AddResourceToClusterSharedVolumes
        ///</summary>
        [TestMethod]
        public void AddResourceToClusterSharedVolumesTest()
        {
            Assert.Inconclusive("A method AddResourceToClusterSharedVolumes implemented but not tested. Wait develeper communit to test.");
        }

        /// <summary>
        ///A test for AddNode
        ///</summary>
        [TestMethod]
        public void AddNodeTest()
        {
            Assert.Inconclusive("A method AddNode implemented but not tested. Wait develeper communit to test.");
        }

    }
}
